package com.basic.business.common.enums;

import java.util.Objects;

/**
 * 订单系统状态枚举类
 *
 * @author zhaoxy_jn@163.com
 */
public enum OrdersStatusEnum {

    WAIT_BUYER_PAY("待付款"),
    WAIT_AUDIT("待审核"),
    WAIT_FINANCE_AUDIT("等待财审"),
    WAIT_MANUAL_AUDIT("等待人工审核"),
    FINISHED_AUDIT("审核完成"),
    WAIT_EXPRESS_PRINT("待打印快递单"),
    SYS_STATUS_WAIT_DELIVERY_PRINT("待打印发货单"),
    WAIT_PACKAGE("待打包"),
    WAIT_WEIGHT("待称重"),
    WAIT_SEND_GOODS("待发货"),
    WAIT_DEST_SEND_GOODS("待供销商发货"),
    SELLER_SEND_GOODS("卖家已发货"),
    FINISHED("交易完成"),
    CLOSED("交易关闭"),
    CANCEL("交易作废");

    private final String description;

    OrdersStatusEnum(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据状态码获取枚举值
     *
     * @param status 状态码
     * @return 对应的枚举值，如果找不到则返回null
     */
    public static OrdersStatusEnum fromStatus(String status) {
        for (OrdersStatusEnum sysStatus : OrdersStatusEnum.values()) {
            if (sysStatus.name().equals(status)) {
                return sysStatus;
            }
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(Objects.requireNonNull(OrdersStatusEnum.fromStatus("WAIT_BUYER_PAY")).getDescription());
    }

}
